"""
搜索页面
"""
import allure
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

import config
from base.base_page import BasePage


class Search(BasePage):

    @allure.step(title='输入搜索内容')
    def input_search_field(self, search_mess):
        self._params['value'] = search_mess
        self.steps(config.BASE_DIR + '/page/yaml_page/search.yaml')
        self.allure_screenshot('输入搜索内容')

    @allure.step(title='点击自选按钮')
    def click_add_customize_stok_button(self, ident_mess):
        self._params['value'] = ident_mess
        self.steps(config.BASE_DIR + '/page/yaml_page/search.yaml')
        self.allure_screenshot('点击自选按钮')

    @allure.step(title='取消自选按钮')
    def cancel_add_customize_stok_button(self, ident_mess):
        self._params['value'] = ident_mess
        self.steps(config.BASE_DIR + '/page/yaml_page/search.yaml')
        self.allure_screenshot('取消自选按钮')

    @allure.step(title='判断是否添加自选')
    def check_is_choose(self, ident_mess):
        self._params['value'] = ident_mess
        return self.steps(config.BASE_DIR + '/page/yaml_page/search.yaml')

    @allure.step(title='点击添加自选流程')
    def click_add_customize(self, search_mess, ident_mess):
        self.input_search_field(search_mess)
        if self.check_is_choose(ident_mess):
            self.cancel_add_customize_stok_button(ident_mess)
        self.click_add_customize_stok_button(ident_mess)
        self.allure_screenshot('点击添加自选流程')
        return self.check_is_choose(ident_mess)
